import axios from '@/libs/api.request'
import {
  format
} from 'path';
import {
  getToken,
  URL
} from "@/libs/util";

// 以防命名冲突
const HOST = URL

/** 事项类别定制数据
 * @param {*} token
 * @param {*} formData  数据
 * @param {*} objKey    对象的KEY
 * @returns
 */
function categoryData(formData, keyOne) {
  let data = {}
  data['tokenEntity'] = {
    value: getToken()
  };
  data[keyOne] = {
    id: formData.id, // id
    itemId: formData.itemId, // 类别选项id
    typeName: formData.typeName, // 加分名称
    itemList: formData.itemList, // 类别选项数组
    pointsType: formData.pointsType,
    datetime: formData.datetime, // 年份
    typeClass: formData.typeClass // 加分类别

  }
  return data
}

// 事项类别定制请求  category
export const categoryAjax = ({
  formData,
  url,
  keyOne
}) => {
  let data = ''
  data = categoryData(formData, keyOne)
  return axios.request({
    url: HOST + url,
    data,
    method: 'post'
  })
}
